package com.yilin.tms.core.entity.system.system;


import com.baomidou.mybatisplus.annotation.EnumValue;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yilin.tms.core.commons.base.BaseEntity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.List;
import java.util.Map;

@Entity
@Table(name = "sys_menu")
@TableName("sys_menu")
public class Menu extends BaseEntity implements Serializable {

    public enum MenuType {
        layout(0, "目录"), source(1, "资源");
        @EnumValue
        public int index;
        public String name;

        MenuType(int index, String name) {
            this.index = index;
            this.name = name;
        }
    }
    /// #### 基本信息
    @Column(name = "code")
    private String code;//唯一码
    @Column(name = "title")
    private String title;//中文标题
    @Column(name = "icon")
    private String icon;//图标
    @Column(name = "parent_id")
    private String parentId;//上级Id
    @Column(name = "menu_level")
    private Integer menuLevel;//菜单等级
    @Column(name = "menu_type")
    private MenuType menuType;//菜单类型
    @Column(name = "soft")
    private Integer soft = 0; //排序
    /// #### 菜单指向 VUE 专用
    @Column(name = "name")
    private String name;//文件名称，和VUE文件Name导出一致
    @Column(name = "path")
    private String path;//路径，只支持单路径，根目录要加"/"
    @Column(name = "component")
    private String component;//VUE文件，以"@/"开头，目录用“Layout”

    // ##用户类型 如 shipperUser,truckerUser 等
    @Column(name = "target_user_types")
    private String targetUserTypes;



    @Transient
    @TableField(exist = false)
    private Boolean checked;//定义节点是否选中
    @Transient
    @TableField(exist = false)
    private Boolean spread;//定义树是否展开

    @Transient
    @TableField(exist = false)
    private List<Menu> children;//封装成树型层级
    @Transient
    @TableField(exist = false)
    private List<MenuOperate> menuOperateList;//操作
    @Transient
    @TableField(exist = false)
    private Long childrenCount;//封装成树型层级
    @Transient
    @TableField(exist = false)
    private List<Object> checkArr;//用户前台checkbox勾选状态
    @Transient
    @TableField(exist = false)
    private Boolean hasChildren;


    public List<MenuOperate> getMenuOperateList() {
        return menuOperateList;
    }

    public void setMenuOperateList(List<MenuOperate> menuOperateList) {
        this.menuOperateList = menuOperateList;
    }

    public Boolean getHasChildren() {
        return hasChildren;
    }

    public void setHasChildren(Boolean hasChildren) {
        this.hasChildren = hasChildren;
    }

    public Long getChildrenCount() {
        return childrenCount;
    }

    public void setChildrenCount(Long childrenCount) {
        this.childrenCount = childrenCount;
    }

    public String getTargetUserTypes() {
        return targetUserTypes;
    }

    public void setTargetUserTypes(String targetUserTypes) {
        this.targetUserTypes = targetUserTypes;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public Integer getMenuLevel() {
        return menuLevel;
    }

    public void setMenuLevel(Integer menuLevel) {
        this.menuLevel = menuLevel;
    }

    public MenuType getMenuType() {
        return menuType;
    }

    public void setMenuType(MenuType menuType) {
        this.menuType = menuType;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public String getComponent() {
        return component;
    }

    public void setComponent(String component) {
        this.component = component;
    }

    public Integer getSoft() {
        return soft;
    }

    public void setSoft(Integer soft) {
        this.soft = soft;
    }

    public Boolean getChecked() {
        return checked;
    }

    public void setChecked(Boolean checked) {
        this.checked = checked;
    }

    public Boolean getSpread() {
        return spread;
    }

    public void setSpread(Boolean spread) {
        this.spread = spread;
    }

    public List<Menu> getChildren() {
        return children;
    }

    public void setChildren(List<Menu> children) {
        this.children = children;
    }

    public List<Object> getCheckArr() {
        return checkArr;
    }

    public void setCheckArr(List<Object> checkArr) {
        this.checkArr = checkArr;
    }
}
